Skip to content

sched_setaffinity: Validate user memory before reading CPU mask#2145

Merged
francescolavra merged 1 commit intomasterfrom
fix/setaffinity
Mar 9, 2026
Merged

sched_setaffinity: Validate user memory before reading CPU mask#2145
francescolavra merged 1 commit intomasterfrom
fix/setaffinity

Conversation

@francescolavra
Copy link
Member

If the CPU mask pointer supplied as argument to sched_setaffinity() is not verified to belong to user memory, a program could pass an arbitrary address and determine from the syscall return value whether that address is mapped as kernel memory, thus defeating KASLR.
Add a call to validate_user_memory() before accessing the CPU mask pointer, and to avoid a double validation replace the copy_from_user() call with a direct memory copy.

Issue reported and fix suggested by Niklas Femerstrand (@niklasfemerstrand).

If the CPU mask pointer supplied as argument to sched_setaffinity() is not
verified to belong to user memory, a program could pass an arbitrary
address and determine from the syscall return value whether that address is
mapped as kernel memory, thus defeating KASLR.
Add a call to validate_user_memory() before accessing the CPU mask pointer,
and to avoid a double validation replace the copy_from_user() call with a
direct memory copy.
@francescolavra francescolavra merged commit ef2e387 into master Mar 9, 2026
7 checks passed
@francescolavra francescolavra deleted the fix/setaffinity branch March 9, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants